﻿using System.Diagnostics;
using System.Windows.Forms;

namespace System
{
  public enum LogType
  {
    ERROR,
    INFO,
    WARN
  }

  [DebuggerStepThrough]
  public static class LogExtensions
  {
    public static void Log(this Form frm, Exception ex)
    {
      Logger.log.Error(ex);
    }

    public static void Log(this Form frm, LogType type, string message)
    {
      switch (type)
      {
        case LogType.ERROR:
          {
            Logger.log.Error(message);
          }
          break;
        case LogType.INFO:
          {
            Logger.log.Info(message);
          }
          break;
        case LogType.WARN:
          {
            Logger.log.Warn(message);
          }
          break;
      }
    }

    public static void Log(this Exception ex)
    {      
      Logger.log.Error(ex);

      //Log inner exception if exists
      if (ex.InnerException == null)
      {
        Logger.log.Error(ex.InnerException);
      }
    }
    public static void Log(this Exception ex, object moreInformation)
    {
      Logger.log.Error(ex);
      Logger.log.Error(moreInformation);

      //Log inner exception if exists
      if (ex.InnerException == null)
      {
        Logger.log.Error(ex.InnerException);
      }
    }

  }
}